package com.hinnotek.amoeba.ui.activity.old

import android.os.Bundle
import android.view.*
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lee.common.base.BaseActivity
import com.hinnotek.amoeba.R
import com.hinnotek.amoeba.adapters.old.SellProjectRequirementListAdapter
import com.hinnotek.amoeba.bean.old.ProjectBean
import com.hinnotek.amoeba.databinding.ActivityProjectRequirementsDetailsBinding
import com.hinnotek.amoeba.utilities.IntentUtils
import com.hinnotek.amoeba.utilities.ToastUtils
import java.util.*


class SellProjectRequirementListActivity :
    BaseActivity<ActivityProjectRequirementsDetailsBinding>() {
    private var mAdapter: SellProjectRequirementListAdapter? = null
    private val stringList: MutableList<ProjectBean> = mutableListOf()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_project_requirements_details)
        setLeftVisible(true)
        setTitle("项目需料")
        setRightText("删除")?.setOnClickListener {
            val list: MutableList<String> = ArrayList()
            for (projectBean in stringList) {
                if (projectBean.b == 1) {
                    list.add(projectBean.id)
                }
            }
            ToastUtils.show(mContext, list.size.toString() + "")
        }

    }

    override fun initVew() {
        val manager = LinearLayoutManager(this)
        manager.orientation = RecyclerView.VERTICAL
        bindingView.rlv.layoutManager = manager
        bindingView.rlv.setAdapter(SellProjectRequirementListAdapter().also { mAdapter = it })
        mAdapter!!.setOnItemClickListener { adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int ->
            IntentUtils.startActivity(
                this,
                SellProjectRequirementsAddActivity::class.java
            )
        }
    }

    override fun setData() {
        for (i in 0..9) {
            stringList.add(ProjectBean(i.toString() + "", 0))
        }
        mAdapter!!.setList(stringList)
    }
}